// Package main
// Created by GoLand
// @User: lenora
// @Date: 2023/12/17
// @Time: 15:07

//go:build wireinject

package main

import (
	"camp/microbook/interactive/events"
	repository2 "camp/microbook/interactive/repository"
	cache2 "camp/microbook/interactive/repository/cache"
	dao2 "camp/microbook/interactive/repository/dao"
	service2 "camp/microbook/interactive/service"
	article_enent "camp/microbook/internal/events/article"
	artsjob "camp/microbook/internal/job/article"
	"camp/microbook/internal/repository"
	"camp/microbook/internal/repository/cache"
	"camp/microbook/internal/repository/dao"
	"camp/microbook/internal/repository/dao/article"
	"camp/microbook/internal/service"
	"camp/microbook/internal/web"
	ijwt "camp/microbook/internal/web/jwt"
	"camp/microbook/ioc"
	"github.com/google/wire"
)

var rankingSvcSet = wire.NewSet(
	cache.NewRedisRankingCache,
	//cache.NewLocalRankingCache,
	repository.NewRankingRepository,
	service.NewArticleRankingService,
	artsjob.NewRankingJob,
)

func InitWebServer() *App {
	wire.Build(
		/*ioc.InitLimiter, ioc.InitFailover, ioc.InitSmsAuth, */ ioc.InitLogger,
		//第三方依赖
		ioc.InitDb, ioc.InitRedis, ioc.InitSaramaClient, ioc.InitSyncProducer, ioc.InitConsumers, ioc.InitRLockClient,
		//
		/*sms.NewTopService,*/
		ioc.InitSmsService, ioc.InitWechat, ioc.InitInteractiveClient,
		//领域对象操作--db
		dao.NewUserDAO, article.NewGormArticleDao, dao2.NewGORMInteractiveDAO,
		//领域对象操作--cache
		cache.NewUserCache, cache.NewCodeCache, cache.NewArticleRedisCache, cache2.NewInteractiveRedisCache,
		//repository
		repository.NewCodeRepository, repository.NewUserRepository, repository.NewArticleRepository, repository2.NewInteractiveRepository,
		//event
		article_enent.NewSaramaSyncProducer, events.NewInteractiveReadConsumer,
		//svc
		service.NewCodeService, service.NewUserService, service.NewArticleService, service2.NewInteractiveService,
		//handler
		web.NewCommonHandler, web.NewUserHandler, web.NewWechatHandler, ijwt.NewRedisJWTHandler, web.NewArticleHandler,
		//job
		rankingSvcSet, ioc.InitJobs, ioc.InitJobGroup,
		//http server
		ioc.InitMiddlewares, ioc.InitWebServer,
		wire.Struct(new(App), "*"),
	)
	return new(App)
}

func IntT() *App {
	return new(App)
}
